//获取应用实例
const app = getApp();
// 引入AES.js
var baseJs = require("../../common/base.js");
Page({

  /**
   * 页面的初始数据
   */
  data: {
    uid: "",
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    this.setData({
      uid: wx.getStorageSync('uid'),
    })
  },

  // 确定
  formSubmit: function(e) {
    // console.log(e);
    var that = this;
    var uid = this.data.uid;
    if (e.detail.value.newPasswords != e.detail.value.surePasswords){
      wx.showToast({
        title: "两次密码输入不一致！",
        icon: 'none',
        duration: 1000
      })
      return false;
    }
    wx.request({
      url: baseJs.api + baseJs.encryUrl("method=UpUserPwdByUID&UID=" + uid + "&YuanPWd=" + e.detail.value.yPasswords + "&NewPWd=" + e.detail.value.newPasswords),
      success: function(res) {
        var json = JSON.parse(baseJs.decryUrl(res.data));
        // console.log(json);
        if (json.ResultFlag == 1) {
          wx.showToast({
            title: json.ResultMsg,
            icon: 'none',
            duration: 1000
          })
          setTimeout(function () {
            wx.navigateBack({
              delta: 1
            })
          }, 500)
        } else {
          wx.showToast({
            title: json.ResultMsg,
            icon: 'none',
            duration: 1000
          })
        }
      }
    })
  },
  // 取消
  formReset: function() {
    wx.navigateBack({
      delta: 1
    })
  },
  // 
})